package com.squareshoot.picCheckin;

import java.util.Locale;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;


public class Changelog extends Activity {

	private WebView mWebView;

	String language="en";
	String changelogString = null;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.changelog);

		language = Locale.getDefault().getLanguage();
		if(Common.HIGHDEBUG)
			Log.i(Common.TAG,"Langue : "+language);

		if(!Common.checkValidHtmlPage(Common.getBaseChangelogUrl()+"/"+language+".html"))
			language="en";

		mWebView = (WebView) findViewById(R.id.webview);

		WebSettings webSettings = mWebView.getSettings();
		webSettings.setSavePassword(false);
		webSettings.setSaveFormData(false);
		webSettings.setJavaScriptEnabled(true);
		webSettings.setSupportZoom(false);

		mWebView.setWebChromeClient(new MyWebChromeClient());
		mWebView.loadUrl(Common.getBaseChangelogUrl()+"/"+language+".html");
	}


	final class MyWebChromeClient extends WebChromeClient {
		@Override
		public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
			if(Common.HIGHDEBUG)
				Log.d(Common.TAG, message);
			result.confirm();
			return true;
		}
	}
}
